//
//$Id: islsp_sa.h 663 2011-02-26 10:41:57Z andrew.tsyganov $
#pragma once

#include "projects/islsp/islsp.h"
#include "solvers/sa/sa_common.h"

//__________________________________________________________________________________
template<>
struct solution<Islsp_Solution, sa_tag>:
    public Islsp_Solution
{
public:
    template<class E>
    void move(E* env, random_generator& rnd, double probability)
    {
        for (size_t i = 0; i < t_.size(); ++i)
        {
            if (rnd.next_Double() < probability) 
            {
                /*double d0 = abs(t_[i] - env->problem_.Delta_(i, 0));
                double d1 = abs(t_[i] - env->problem_.Delta_(i, 1));
                double d;

                if (d0 < d1)
                    d = d0;
                else
                    d = d1;
                */
                
                //t_[i] = env->problem_.Delta_(i, 0) + rnd.next_Double()* (env->problem_.Delta_(i, 1) - env->problem_.Delta_(i, 0));
                
                double t = t_[i] + 0.1*rnd.next_Normal(0, 1);

                if (t < env->problem_.Delta_(i, 0)) 
                    t_[i] = env->problem_.Delta_(i, 0);
                else
                    if (t > env->problem_.Delta_(i, 1))
                        t_[i] = env->problem_.Delta_(i, 1);
                    else
                        t_[i] = t;
                        

                //t_[i] += 20*rnd.next_Normal(0, 1);
            }
        }

        changed_ = true;
    }
};
//__________________________________________________________________________________

//EOF!
